﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using BrettM.Web.Hosting;
using Microsoft.Practices.Unity;

namespace BrettM.BootStrappers
{
    /// <summary>
    /// Registers the default ASP.NET MVC 2 routes
    /// </summary>
    public class DefaultMvcRoutesBootStrapper 
        : IBootStrapper
    {
        public void OnStart(IUnityContainer container, PropertyBag bag)
        {
            var routes = RouteTable.Routes;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }

        public void OnStop(IUnityContainer container, PropertyBag bag)
        {
            RouteTable.Routes.Clear();
        }

        public void Dispose()
        {
        }
    }
}
